export function getDiologFormDataFn(obj: ISudAGetData, dataed: Ref<ISudRGetData>): Ref<ISudRGetData> {
  dataed.value = {
    superFormOpt: obj.superFormOpt,
    open: obj?.superFormOpt?.open ?? false,
    subLoading: false,
    formType: obj.formType,
    formEmitsObj: obj.formEmitsObj,
    formPropsObj: obj.formPropsObj,
    emit: obj.emit
  };
  return dataed;
}
export function getDiologFormMethodsFn(data: Ref<ISudRGetFn>): ISudRGetFn {
  const methods: ISudOMethods = {
    showDialogFn(params) {
      data.value.open = true;
      nextTick(() => {
        data.value.formRef.resetfileFn(params || data.value.formPropsObj.formParams);
      });
    },
    submitFormFn: async () => {
      try {
        let res = await data.value.formRef?.submitFormFn();
        if (!res) return;
        data.value.subLoading = true;
        if (!data.value.superFormOpt?.notSaveAfter)
          data.value.emit("emitGetListFn", {
            fn: () => {
              ElMessage.success("保存成功");
              data.value.open = false;
              data.value.subLoading = false;
            }
          });
      } catch (error) {
        console.log(error);
        data.value.subLoading = false;
      }
    }
  };
  data.value.methods = methods;
  return data.value;
}
